import cv2 as cv

img = cv.imread(r'temp.jpg')
cv.imshow('hello world',img)

#GaussianBlur  test
img_Gauss = cv.GaussianBlur(img,(5,5),0)
cv.imshow("Gauss",img_Gauss)

#修改图像大小
img_size = cv.resize(img,(int(img.shape[1]/2),int(img.shape[0]/2)))#shape[行数,列数,通道数]
img_size2 = cv.pyrDown(img_size) #将对象尺寸缩小一半
cv.imshow('size',img_size)
cv.imshow('size2',img_size2)

#二值化  阈值化
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
a,gray_2 = cv.threshold(gray,120,0xff,cv.THRESH_BINARY) #函数返回两个对象第一个返回阈值，第二个返回对象
cv.imshow("gray",gray)
cv.imshow("Binary",gray_2)

cv.waitKey() #等待按下任意键 中间可以加数字
cv.destroyAllWindows()